<template>
    <view>
        <u-button type="primary" @click="ScanCode">确定</u-button>
    </view>
</template>
<script>
    export default{
        data(){
            return{
                EAN:undefined
            }
        },
        onLoad(options) {},
        onShow() {},
        methods: {
            // 扫码，扫描之后自动调用查询事件
            ScanCode() {
                // #ifdef APP-PLUS || MP-WEIXIN
                uni.scanCode({
                    onlyFromCamera: true,
                    scanType: ['barCode', 'qrCode'], //条形码+二维码
                    success: function (res) {
                        console.log('条码类型：' + res.scanType);
                        console.log('条码内容：' + res.result);
                        if(res.scanType){
                            this.vibrateShort() //短震动
                        }else{
                            this.vibrateLong() //长震动
                            uni.showToast({
                                icon: "none",
                                title: "请扫描条形码",
                                duration: 1500
                            })
                        }
                    }
                });
                // #endif
                // #ifdef H5
                console.log("....")
                // #endif
            }
            
            
        },
    }
</script>
<style scoped lang="scss">
</style>